/**
 * @project_name staff_vehicle
 * @package_name com.ssh.web
 * @desc TODO
 * @param
 * @author jack
 * @date 2013-5-1
 * @time 上午11:10:04
 */
package com.ssh.web;

import java.util.Map;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
import com.ssh.entity.Staff;

/**
 * @author jack
 * @desc 登陆验证
 */
public class LoginInterceptor extends AbstractInterceptor {

	/**
	 * TODO
	 */
	private static final long serialVersionUID = 1L;

	@SuppressWarnings("unchecked")
	@Override
	public String intercept(ActionInvocation invocation) throws Exception {
		Map session = ActionContext.getContext().getSession();
		Staff staff = (Staff) session.get("staff");
		if (staff != null) {
			// 正确登录，验证是否重复提交
			return invocation.invoke();
		} else {
			// 未正确登录
			session.put("message", "登录信息丢失，请重新登录！");
			return "noLogin";
		}
	}

	@Override
	public void destroy() {
		// TODO Auto-generated method stub
		super.destroy();
	}

	@Override
	public void init() {
		// TODO Auto-generated method stub
		super.init();
	}

}
